﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

namespace TemplateApiCore
{
    public static class CorsExtension
    {
        public static void AddCorsExtension(this WebApplicationBuilder builder)
        {
            builder.Services.AddCors(options =>
            {
                options.AddPolicy("AllowAll",
                    builder =>
                    {
                        builder.AllowAnyOrigin()
                               .AllowAnyHeader()
                               .AllowAnyMethod();
                    });
            });
        }

        public static void UseCorsExtension(this WebApplication app)
        {
            app.UseCors("AllowAll");
        }
    }
}
